package com.gxa.weixing.core.util;

import com.gxa.weixing.core.common.ExceptionCode;
import com.gxa.weixing.core.exception.BusinessException;

import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;

/**
 * @author yang
 * @date 2022/1/12 15:58
 */
public class TimeToDate {


    public static void time(List<Map<String, Object>> map, String name) throws BusinessException {
        try {
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            for (Map<String, Object> stringObjectMap : map) {
                Object orderTime = stringObjectMap.get(name);
                stringObjectMap.put(name, simpleDateFormat.format(orderTime));
            }
        } catch (Exception e) {
            throw new BusinessException(ExceptionCode.FORMAT_COMVERSION_ERROR);
        }
    }
}
